#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include "swupdate.h"
#include <QQmlContext>
#include <QLockFile>
#include <QDebug>
#include <QDir>

int main(int argc, char *argv[])
{

    QString tempPath = QDir::temp().absoluteFilePath("Swupdate_progress.lock");
    QLockFile lockfile_(tempPath);
    if(!lockfile_.tryLock(0)){
        qDebug()<<"This program has been runing,please check it.";
        return 1;
    }

    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

    QGuiApplication app(argc, argv);
    SWUpdate swupdate;
    QQmlApplicationEngine engine;
    engine.rootContext()->setContextProperty("Swupdate",&swupdate);

    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    if (engine.rootObjects().isEmpty())
        return -1;

    return app.exec();
}
